#ifndef QREMOTEOBJECTADVANCE_GLOBAL_H
#define QREMOTEOBJECTADVANCE_GLOBAL_H

#include <QtCore/qglobal.h>
#include <QObjectBindableProperty>

#if defined(QREMOTEOBJECTADVANCE_LIBRARY)
#  define QREMOTEOBJECTADVANCE_EXPORT Q_DECL_EXPORT
#else
#  define QREMOTEOBJECTADVANCE_EXPORT Q_DECL_IMPORT
#endif


#define Q_CLASS_NAME(NAME)    \
typedef NAME ClassName;


#define Q_BINDABLE_PROPERTY_AUTO(TYPE, M)                                                                                       \
  Q_PROPERTY(TYPE M READ M WRITE M NOTIFY M##Changed BINDABLE M##Bindable)                                                                     \
public:                                                                                                                \
  Q_SIGNAL void M##Changed(TYPE);                                                                                          \
  void M(TYPE val)                                                                                                  \
  {                                                                                                                    \
    _##M = val;                                                                                                                                                                                                   \
  }                                                                                                                    \
  TYPE M()                                                                                                             \
  {                                                                                                                    \
    return _##M;                                                                                                       \
  }                                                                                                                    \
QBindable<TYPE> M##Bindable(){ \
    return &_##M; \
  } \
private:                                                                                                               \
  Q_OBJECT_BINDABLE_PROPERTY(ClassName,TYPE,_##M,&ClassName::M##Changed);                                          \



#define Q_BINDABLE_PROPERTY_AUTO_READONLY(TYPE, M)                                                                                       \
  Q_PROPERTY(TYPE M READ M NOTIFY M##Changed BINDABLE M##Bindable)                                                                     \
public:                                                                                                                \
  Q_SIGNAL void M##Changed(TYPE);                                                                                          \
  TYPE M()                                                                                                             \
  {                                                                                                                    \
    return _##M;                                                                                                       \
  }                                                                                                                    \
QBindable<TYPE> M##Bindable(){ \
    return &_##M; \
  } \
private:                                                                                                               \
  void M(TYPE val)                                                                                                  \
  {                                                                                                                    \
    _##M = val;                                                                                                     \
} \
  Q_OBJECT_BINDABLE_PROPERTY(ClassName,TYPE,_##M,&ClassName::M##Changed);                                          \


#endif // QREMOTEOBJECTADVANCE_GLOBAL_H
